repo: don't forget to abort the transaction when failed
authorCosimo Cecchi <cosimo@endlessm.com>
Tue, 28 Jul 2015 00:17:26 +0000 (17:17 -0700)
committerColin Walters <walters@verbum.org>
Tue, 28 Jul 2015 15:35:42 +0000 (11:35 -0400)
ostree_repo_prepare_transaction() should always be matched with a call
to either ostree_repo_commit_transaction() or
ostree_repo_abort_transaction().

Since ostree_repo_pull_with_options() does not call
ostree_repo_abort_transaction() on errors, the OstreeRepo instance will
hit an assertion when it's re-used later for another attempt, such as
when the update is driven by an external component through libostree and
network temporarily goes down.

This commit simply always calls ostree_repo_abort_transaction() in the
exit path of ostree_repo_pull_with_options(), since the function is safe
to call even when we're not in a transaction, and that matches e.g. what
ostree-sysroot-cleanup.c does.

src/libostree/ostree-repo-pull.c

index aa8e6359d7dc39b3dff7d09947fe0e8bb3f7b058..5a87847bc8a1a6892d368f1dc8e09860486b0f5c 100644 (file)
@@ -2191,6 +2191,7 @@ ostree_repo_pull_with_options (OstreeRepo             *self,
 
   ret = TRUE;
  out:
+  ostree_repo_abort_transaction (pull_data->repo, cancellable, NULL);
   g_main_context_unref (pull_data->main_context);
   if (update_timeout)
     g_source_destroy (update_timeout);